package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Income;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

/**
 * <p>
 * 收入表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-10-29
 */
@Mapper
public interface IncomeMapper extends BaseMapper<Income> {

    @Select("select sum(amount) from housekeeper.income where time between #{beginTime} and #{endTime};")
    Double getAmounts2(LocalDate beginTime, LocalDate endTime);

    @Select("select sum(amount) from housekeeper.income where time = #{time};")
    Double getAmounts1(LocalDate time);

    @Select("select sum(amount) from housekeeper.income where time between #{beginTime} and #{endTime} and type_key = #{typeKey};")
    Double getAmounts(LocalDate beginTime, LocalDate endTime,int typeKey);

}
